//
//  AuthenView2ViewController.m
//  YTwallet
//
//  Created by ZhangLin on 2019/3/7.
//  Copyright © 2019年 hadrlog. All rights reserved.
//

#import "AuthenView2ViewController.h"
#import "AuthenView.h"
#import "AuthenTableViewCell.h"
#import "AgreeProtocolView.h"
#import <Masonry.h>
#import "AppDelegate.h"
#import "SelectCityView.h"
#import "AuthenResultViewController.h"
#import "BankListView.h"

//选择银行卡列表
#import "AddressView.h"
#import "BankListModelPack.h"
//实名认证
#import "BasicsAuthenModelPack.h"

#import "RSA.h"
#import <UIImageView+WebCache.h>
#import "BankListTableViewCell.h"

#import "OpenDoc.h"
#import "ServeWebViewController.h"

@interface AuthenView2ViewController ()<UITableViewDataSource,UITableViewDelegate,UIGestureRecognizerDelegate,UITextFieldDelegate,openDocDelegate>
@property(nonatomic,strong)UITableView *tableView;
@property(nonatomic,strong)NSMutableArray *titleArray;
@property(nonatomic,strong)NSMutableArray *titleValueArray;
@property(nonatomic,strong)NSMutableArray *attTitleValueArray;
@property(nonatomic,strong)UIButton *nextStypeBtn;
@property(nonatomic,strong)AgreeProtocolView *agreeProtecolView;
@property(nonatomic,strong)OpenDoc *opendoc;

//银行名称选择
@property(nonatomic,strong)UITextField *banNameTf;
//银行所在地选择
@property(nonatomic,strong)UITextField *bankAddressTf;


//弹出银行名称
@property(nonatomic,strong)BankListView *bv;
//银行名称模型数组
@property(nonatomic,strong)NSMutableArray *bankNameArray;


@property(nonatomic,strong)AuthenView *av;

//tableView里面的输入框(方便获取操作)
@property(nonatomic,strong)UITextField *nameTf;
@property(nonatomic,strong)UITextField *banCardTf;
@property(nonatomic,strong)UITextField *bankPhoneTf;



@property(nonatomic,strong)AddressView *addressView;


/**
 银行编码(简称)
 */
@property(nonatomic,strong)NSString *bankCodeStr;


/**
 键盘上方的完成
 */
@property(nonatomic,strong)UIToolbar *toolbar;

@end

@implementation AuthenView2ViewController

-(NSMutableArray *)attTitleValueArray
{
    if (_attTitleValueArray == nil) {
        _attTitleValueArray = [NSMutableArray array];
    }
    return _attTitleValueArray;
}

-(NSMutableArray *)titleArray
{
    if (_titleArray == nil) {
        _titleArray = [NSMutableArray array];
    }
    return _titleArray;
}

-(NSMutableArray *)titleValueArray
{
    if (_titleValueArray == nil) {
        _titleValueArray = [NSMutableArray array];
    }
    return _titleValueArray;
}

-(NSMutableArray *)bankNameArray
{
    if (_bankNameArray == nil) {
        _bankNameArray = [NSMutableArray array];
    }
    return _bankNameArray;
}

- (void)viewDidLoad {
    [super viewDidLoad];
    self.title = @"实名认证";
    self.view.backgroundColor = [UIColor colorWithRed:242 / 255.0 green:244 / 255.0 blue:246 / 255.0 alpha:1];
    //创建tableView(实名认证第一步)
    [self createTableView];
    //创建顶部基本信息展示View
    [self createTopView];
    self.av.tipsLab.text = @"填写收款卡信息";
    
    NSMutableAttributedString *attributedString = [[NSMutableAttributedString alloc] initWithString:@"2/2"];
    [attributedString addAttribute:NSForegroundColorAttributeName value:[UIColor colorWithRed:91.0f/255.0f green:113.0f/255.0f blue:255.0f/255.0f alpha:1.0f] range:NSMakeRange(0, 1)];
    
    
    [attributedString addAttribute:NSForegroundColorAttributeName value:[UIColor colorWithRed:51.0f/255.0f green:51.0f/255.0f blue:51.0f/255.0f alpha:1.0f] range:NSMakeRange(1, 2)];
    
    self.av.stypeLab.attributedText = attributedString;
    //提交
    [self createNextStype];
    //同意协议
    [self createAgreeProtecolView];
}

-(void)textFieldDidEndEditing:(UITextField *)textField
{
    //当银行卡号失去焦点时,请求后端的银行
    if (textField == self.banCardTf && textField.text.length != 0) {
        [self getBankListWithCardNum:self.banCardTf.text];
    }
}


-(void)offBtnAction
{
    [self BankListViewdismiss];
}

-(void)getBankListWithCardNum:(NSString *)cardNum
{
    
    if (cardNum.length != 0) {
        [self NoTipsNetWithCardNum:cardNum];
    }else
    {
        [self TipsNetWithCardNum];
    }
    
}

//无提示框请求银行列表
-(void)NoTipsNetWithCardNum:(NSString *)cardNum
{
    BankListRequest *request = [[BankListRequest alloc] init];
    request.cardNo = cardNum;
    NSDictionary *dic = [request mj_keyValues];
    NSString *url = [[ServerAddressModel shareInstance] fullTAnd0AddrWithParameter:@"/epay_apps/bankCard/getBankByCardNo"];
    [[ETONEHttpClient sharedInstance] doHTTPSPOSTNOTips:url Parameters:dic HttpBody:nil SuccessHandler:^(id responseObject) {
        
        NSDictionary *dic = [responseObject mj_JSONObject];
        NSString *code = dic[@"code"];
        if ([@"0000" isEqualToString:code]) {
            dispatch_async(dispatch_get_main_queue(), ^{
                [self dealbankListWithResponse:responseObject];
            });
        }else
        {
            self.banNameTf.text = @"";
            self.tableView.userInteractionEnabled = YES;
        }
    } FailedHandler:^(NSError *error) {
        
        self.tableView.userInteractionEnabled = YES;
        
    }];
}
//有提示框请求银行列表
-(void)TipsNetWithCardNum
{
    BankListRequest *request = [[BankListRequest alloc] init];
    request.cardNo = @"";
    NSDictionary *dic = [request mj_keyValues];
    NSString *url = [[ServerAddressModel shareInstance] fullTAnd0AddrWithParameter:@"/epay_apps/bankCard/getBankByCardNo"];
    [[ETONEHttpClient sharedInstance] doHTTPSPOST:url Parameters:dic HttpBody:nil SuccessHandler:^(id responseObject) {
        
        NSDictionary *dic = [responseObject mj_JSONObject];
        NSString *code = dic[@"code"];
        if ([@"0000" isEqualToString:code]) {
            dispatch_async(dispatch_get_main_queue(), ^{
                [self dealbankListWithResponse:responseObject];
            });
        }else
        {
            self.banNameTf.text = @"";
            self.tableView.userInteractionEnabled = YES;
        }
    } FailedHandler:^(NSError *error) {
        
        self.tableView.userInteractionEnabled = YES;
        
    }];
}




-(void)dealbankListWithResponse:(id )responseObject
{
    BankListResponse *bankListResponse = [BankListResponse mj_objectWithKeyValues:responseObject];
    NSLog(@"%@",bankListResponse);
    
    if (bankListResponse.response.bankList.count == 1) {
        //输入框赋值
        BankListRecord *record = bankListResponse.response.bankList[0];
        self.banNameTf.text = record.text;
        self.bankCodeStr = record.value;
    }else
    {
        [self popBanList];
        
        
        [self.bv.offBtn addTarget:self action:@selector(offBtnAction) forControlEvents:(UIControlEventTouchDown)];
        [self.bankNameArray removeAllObjects];
        for (BankListRecord *record in bankListResponse.response.bankList) {
            //存储到数组,点击时直接取数据
            [self.bankNameArray addObject:record];
        }
        [self.bv.bankListTableView reloadData];
    }
}

-(void)createAgreeProtecolView
{
    self.agreeProtecolView = [[AgreeProtocolView alloc] init];
    [self.view addSubview:self.agreeProtecolView];
    [self.agreeProtecolView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(0);
        make.right.mas_equalTo(0);
        make.bottom.equalTo(self.nextStypeBtn.mas_top).offset(-20);
        make.height.mas_equalTo(44);
    }];
    
    [self.agreeProtecolView.radioBtn addTarget:self action:@selector(radioBtnAction) forControlEvents:(UIControlEventTouchUpInside)];
     [self.agreeProtecolView.layerBtn addTarget:self action:@selector(servcload) forControlEvents:(UIControlEventTouchUpInside)];
     [self.agreeProtecolView.serveBtn addTarget:self action:@selector(layerload) forControlEvents:(UIControlEventTouchUpInside)];
}
-(void)layerload{
      NSString *url = [[ServerAddressModel shareInstance] fullTAnd0AddrWithParameter:@"file/fuwu.pdf"];
    [self.opendoc downloadPDF:url];
}
-(void)servcload{
    NSString *url = [[ServerAddressModel shareInstance] fullTAnd0AddrWithParameter:@"file/yingsi.pdf"];
    [self.opendoc downloadPDF:url];
}
-(void)rebackDocPath:(NSString *)path{
    ServeWebViewController *sev = [[ServeWebViewController alloc] init];
    sev.filePath = path;
    [self.navigationController pushViewController:sev animated:NO];
    
}
-(void)radioBtnAction
{
    self.agreeProtecolView.radioBtn.selected = !self.agreeProtecolView.radioBtn.selected;
}

-(void)createNextStype
{
    self.nextStypeBtn = [UIButton buttonWithType:(UIButtonTypeCustom)];
    self.nextStypeBtn.backgroundColor = [UIColor colorWithRed:91 / 255.0 green:113 / 255.0 blue:255 / 255.9 alpha:1];
    [self.nextStypeBtn setTitle:@"提交" forState:(UIControlStateNormal)];
    [self.nextStypeBtn setTitleColor:[UIColor whiteColor] forState:(UIControlStateNormal)];
    self.nextStypeBtn.titleLabel.font = [UIFont systemFontOfSize:16];
    self.nextStypeBtn.frame = CGRectMake(0, self.view.frame.size.height - ETTopHeight - ETTabBarArcHeight - 44, self.view.frame.size.width, 44);
    [self.view addSubview:self.nextStypeBtn];
    [self.nextStypeBtn addTarget:self action:@selector(nextStypeBtnAction) forControlEvents:(UIControlEventTouchUpInside)];
}
-(void)nextStypeBtnAction
{
    if (self.nameTf.text.length == 0) {
        [self showFailedResultTips:@"请填写持卡人姓名" animated:YES forSeconds:FAIL_SHOW_TIME_DEF];
        return;
    }
    if (self.banCardTf.text.length == 0) {
        [self showFailedResultTips:@"请填写银行卡号" animated:YES forSeconds:FAIL_SHOW_TIME_DEF];
        return;
    }
    if (self.bankPhoneTf.text.length == 0) {
        [self showFailedResultTips:@"请填写银行预留手机号" animated:YES forSeconds:FAIL_SHOW_TIME_DEF];
        return;
    }
    
    
    if (self.banNameTf.text.length == 0) {
        [self showFailedResultTips:@"请选择银行名称" animated:YES forSeconds:FAIL_SHOW_TIME_DEF];
        return;
    }
    
    /*
    if (self.bankAddressTf.text.length == 0) {
        [self showFailedResultTips:@"请选择银行所在地" animated:YES forSeconds:FAIL_SHOW_TIME_DEF];
        return;
    }
    */
    
    
    if (!self.agreeProtecolView.radioBtn.selected) {
        [self showFailedResultTips:@"请同意服务协议" animated:YES forSeconds:FAIL_SHOW_TIME_DEF];
        return;
    }
    
    BasicsAuthenRequest *request = [[BasicsAuthenRequest alloc] init];
    request.idNo = [RSA encryptString:self.idNumStr publicKey:ETPublicKeyStr];
    request.name = self.nameStr;
    request.mobile = [RSA encryptString:self.phoneStr publicKey:ETPublicKeyStr];
    request.accountNo = [RSA encryptString:self.banCardTf.text publicKey:ETPublicKeyStr];
    request.accountName = self.nameTf.text;
    request.bankLeaveMobile = [RSA encryptString:self.bankPhoneTf.text publicKey:ETPublicKeyStr];
    request.bankName = self.banNameTf.text;
    request.bankCode = self.bankCodeStr;
    NSString *url = [[ServerAddressModel shareInstance] fullTAnd0AddrWithParameter:@"/epay_apps/user/newRealName"];
    NSDictionary *dic = [request mj_keyValues];
    [[ETONEHttpClient sharedInstance] doHTTPSPOST:url Parameters:dic HttpBody:nil SuccessHandler:^(id responseObject) {
        
        //如果code不等于0000 提示错误信息  否则返回正常数据
        NSDictionary *dic = [responseObject mj_JSONObject];
        NSString *code = dic[@"code"];
        if ([@"0000" isEqualToString:code]) {
            dispatch_async(dispatch_get_main_queue(), ^{
                [self dealAuthenSuccWithObject:responseObject];
            });            
        }
        
    } FailedHandler:^(NSError *error) {
        
    }];
    
}
-(void)dealAuthenSuccWithObject:(id)responseObject
{
    //赋值实名认证姓名、银行卡+1
    [AppTools shareInstance].userInfo.userName = self.nameTf.text;
    [AppTools shareInstance].userInfo.status = @"60";
    [AppTools shareInstance].userInfo.cdrdsNum = @"1";
    /*
    //把登录返回的数据模型存储到本地
    NSData *data = [NSKeyedArchiver archivedDataWithRootObject:[AppTools shareInstance].userInfo];
    [[NSUserDefaults standardUserDefaults] setObject:data forKey:@"u"];
    */
    [self showSuccessResultTips:@"实名认证成功" animated:YES forSeconds:SUCCESS_SHOW_TIME_DEF completionBlock:^{
        AuthenResultViewController *authVC = [[AuthenResultViewController alloc] init];
        [self.navigationController pushViewController:authVC animated:YES];
    }];
}

-(void)createTopView
{
    self.av = [[AuthenView alloc] init];
    self.av.backgroundColor = [UIColor whiteColor];
    self.av.frame = CGRectMake(0, 0, self.view.frame.size.width, 51);
    [self.view addSubview:self.av];
}
-(void)createTableView
{
    /*
    self.titleArray = @[@"持卡人姓名",@"银行卡号",@"银行预留手机号",@"银行名称",@"银行所在地"].mutableCopy;
    self.titleValueArray = @[@"请输入持卡人姓名(需与身份证姓名一致)",@"16位银行卡号(需为储值卡)",@"银行卡预留手机号",@"选择银行名称",@"选择银行所在地"].mutableCopy;
     */
    
    self.titleArray = @[@"持卡人姓名",@"银行卡号",@"银行预留手机号",@"银行名称"].mutableCopy;
    self.titleValueArray = @[@"请输入持卡人姓名(需与身份证姓名一致)",@"16位银行卡号(需为储值卡)",@"银行卡预留手机号",@"选择银行名称"].mutableCopy;
    for (int i = 0; i < self.titleValueArray.count; i++) {
        NSMutableAttributedString *placeholder = [[NSMutableAttributedString alloc] initWithString:self.titleValueArray[i]];
        [placeholder addAttribute:NSForegroundColorAttributeName
                            value:[UIColor colorWithRed:221 / 255.0 green:221 / 255.0 blue:221 / 255.0 alpha:1]
                            range:NSMakeRange(0, [self.titleValueArray[i] length])];
        [placeholder addAttribute:NSFontAttributeName
                            value:[UIFont systemFontOfSize:16]
                            range:NSMakeRange(0, [self.titleValueArray[i] length])];
        
        [self.attTitleValueArray addObject:placeholder];
    }
    
    self.tableView = [[UITableView alloc] initWithFrame:CGRectMake(0, 50, ETScreenW, ETScreenH - 50 - 64 - 100) style:(UITableViewStyleGrouped)];
    self.tableView.delegate = self;
    self.tableView.dataSource = self;
    self.tableView.separatorStyle = UITableViewCellSelectionStyleNone;
//    self.tableView.scrollEnabled = NO;
    [self.view addSubview:self.tableView];
    [self.tableView registerClass:[AuthenTableViewCell class] forCellReuseIdentifier:@"cell"];
}

-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
    if (tableView == self.tableView) {
        return self.titleArray.count;
    }else
    {
        return self.bankNameArray.count;
    }
    
}
-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    
    if (tableView == self.tableView) {
        AuthenTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"cell" forIndexPath:indexPath];
        cell.titleLab.text = self.titleArray[indexPath.row];
        cell.titleValueTf.attributedPlaceholder = self.attTitleValueArray[indexPath.row];
        //点击不变色
        cell.selectionStyle = UITableViewCellSelectionStyleNone;
        if (indexPath.row == 3 || indexPath.row == 4 || indexPath.row == 5) {
            cell.titleValueTf.userInteractionEnabled = NO;
            cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
        }
        //换行设置为完成
        cell.titleValueTf.returnKeyType = UIReturnKeyDone;
        cell.titleValueTf.delegate = self;
        
        [cell.titleValueTf addTarget:self action:@selector(textFieldDidChange:) forControlEvents:(UIControlEventEditingChanged)];
        
        if (indexPath.row == 0) {
            self.nameTf = cell.titleValueTf;
            cell.titleValueTf.text = self.nameStr;
        }else if (indexPath.row == 1)
        {
            self.banCardTf = cell.titleValueTf;
            cell.titleValueTf.keyboardType = UIKeyboardTypeNumberPad;
            cell.titleValueTf.inputAccessoryView = [self addToolbar];
        }else if (indexPath.row == 2)
        {
            self.bankPhoneTf = cell.titleValueTf;
            cell.titleValueTf.keyboardType = UIKeyboardTypeNumberPad;
            cell.titleValueTf.inputAccessoryView = [self addToolbar];
        }
        if (indexPath.row == 3) {
            self.banNameTf = cell.titleValueTf;
        }
        if (indexPath.row == 4) {
            self.bankAddressTf = cell.titleValueTf;
        }
        //最后一条不显示分割线
        if (indexPath.row == self.titleArray.count - 1) {
            cell.lineView.hidden = YES;
        }
        return cell;
    }else
    {
        BankListTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"bankListCell" forIndexPath:indexPath];
        BankListRecord *record = self.bankNameArray[indexPath.row];
        [cell.iconImv sd_setImageWithURL:[NSURL URLWithString:record.bankIcon] placeholderImage:[UIImage imageNamed:@"logo_yinhang"]];
        cell.titleLab.text = record.text;
        
        return cell;
    }
}

-(void)textFieldDidChange :(UITextField *)textField{
    
    //CVN2码只能输入3位
    if (textField == self.bankPhoneTf) {
        if (textField.text.length > 11) {
            textField.text = [textField.text substringToIndex:11];
        }
    }
}

//数字键盘加完成按钮
- (UIToolbar *)addToolbar
{
    self.toolbar = [[UIToolbar alloc] initWithFrame:CGRectMake(0, 0, CGRectGetWidth(self.view.frame), 40)];
    self.toolbar.backgroundColor = ETColorWithRGB(232, 232, 232);
    UIBarButtonItem *space = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemFlexibleSpace target:nil action:nil];
    UIButton *btn = [UIButton buttonWithType:(UIButtonTypeCustom)];
    btn.backgroundColor = [UIColor whiteColor];
    [btn setTitle:@"完成" forState:(UIControlStateNormal)];
    [btn setTitleColor:ETColorWithRGB(0, 0, 0) forState:(UIControlStateNormal)];
    btn.layer.borderColor = ETColorWithRGB(0, 0, 0).CGColor;
    btn.layer.borderWidth = 1;
    btn.layer.cornerRadius = 4;
    btn.frame = CGRectMake(0, 0, 76, 28);
    [btn addTarget:self action:@selector(textFieldDone) forControlEvents:(UIControlEventTouchUpInside)];
    UIBarButtonItem *bar = [[UIBarButtonItem alloc] initWithCustomView:btn];
    self.toolbar.items = @[space, bar];
    return self.toolbar;
}
-(void)textFieldDone
{
    [self.view endEditing:YES];
}

-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
    
    NSLog(@"点击tableView");
    if (tableView == self.tableView) {
        
        AuthenTableViewCell *cell = (AuthenTableViewCell *)[self.tableView cellForRowAtIndexPath:indexPath];
        [cell.titleValueTf becomeFirstResponder];
        
        
        //选择银行
        if (indexPath.row == 3) {
            //点击获取银行卡列表  退键盘
            [self.view endEditing:YES];
            self.tableView.userInteractionEnabled = NO;
            [self getBankListWithCardNum:@""];
        }
        //选择银行所在地
        if (indexPath.row == 4) {
            [self btnClick];
        }
    }else if(tableView == self.bv.bankListTableView)
    {
        //退出银行列表
        [self BankListViewdismiss];
        BankListRecord *record = self.bankNameArray[indexPath.row];
        self.banNameTf.text = record.text;
        self.bankCodeStr = record.value;
    }
    
    
    
}

- (void)btnClick{
    //未选择新建View,选择过得弹出View
    if (self.bankAddressTf.text.length == 0) {
        __weak __typeof(self)weakSelf = self;
        self.addressView = [[AddressView alloc] initWithFrame:CGRectMake(0, 0, [UIApplication sharedApplication].keyWindow.frame.size.width, [UIApplication sharedApplication].keyWindow.frame.size.height)WithTitle:self.bankAddressTf.text];
        self.addressView.block = ^(NSString *addressStr){
            weakSelf.bankAddressTf.text = addressStr;
            weakSelf.bankAddressTf.userInteractionEnabled = NO;
            
        };
        [self.addressView showView:self.view];
    }else
    {
        self.addressView.frame = CGRectMake(0, 0, ETScreenW, ETScreenH);
        [UIView animateWithDuration:0.5 animations:^{
            
            self.addressView.myView.frame = CGRectMake(0, ETScreenH - 400, ETScreenW, 400);
            
        } completion:^(BOOL finished) {
        
            
            
        }];

    }
}

-(void)popBanList
{
    
    [self.view endEditing:YES];
    
    self.bv = [[BankListView alloc] initWithFrame:(CGRectMake(0, ETScreenH, ETScreenW, 400))];
    AppDelegate *delegate  = (AppDelegate *)[UIApplication sharedApplication].delegate;
    
    [delegate.window addSubview:self.bv];
    
    
    //给弹出框加上点击事件  响应底部弹窗消失
    UITapGestureRecognizer *tapGesture = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(tapGesturedDetected:)];
    tapGesture.delegate = self;
    [self.bv addGestureRecognizer:tapGesture];
    
    
    __weak AuthenView2ViewController *weakSelf = self;
    self.bv.backgroundColor = [UIColor colorWithRed:0 green:0 blue:0 alpha:0];
    self.bv.userInteractionEnabled = NO;
    [UIView animateWithDuration:0.5 animations:^{
        [weakSelf.bv setFrame:CGRectMake(0, 0, ETScreenW, ETScreenH)];
    } completion:^(BOOL finished) {
        self.bv.userInteractionEnabled = YES;
        self.tableView.userInteractionEnabled = YES;
        weakSelf.bv.backgroundColor = [UIColor colorWithRed:0 green:0 blue:0 alpha:0.4];
    }];
    
    self.bv.bankListTableView.delegate = self;
    self.bv.bankListTableView.dataSource = self;
    self.bv.bankListTableView.userInteractionEnabled = YES;
    self.bv.bankListTableView.tableHeaderView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, ETScreenW, 0.0001f)];
    self.bv.bankListTableView.tableFooterView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, ETScreenW, 0.0001f)];
    [self.bv.bankListTableView registerClass:[BankListTableViewCell class] forCellReuseIdentifier:@"bankListCell"];
    
}

-(CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section
{
    return 0.01f;
}

- (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section{
    
    return nil;
}

-(UIView *)tableView:(UITableView *)tableView viewForFooterInSection:(NSInteger)section
{
    return nil;
}

-(CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section
{
    return 0.01f;
}

-(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
    if (tableView == self.tableView) {
        return 70;
    }else
    {
        return 50;
    }
    
}

-(BOOL)gestureRecognizer:(UIGestureRecognizer *)gestureRecognizer shouldReceiveTouch:(nonnull UITouch *)touch
{
    if ([NSStringFromClass([touch.view class]) isEqualToString:@"UITableViewCellContentView"]) {//如果当前是tableView
        //做自己想做的事
        return NO;
    }
    return YES;
}

-(void)tapGesturedDetected:(UIGestureRecognizer *)tap
{
    CGPoint point = [tap locationInView:self.bv];
    
    if (point.y < ETScreenH - 400) {
        self.bv.backgroundColor = [UIColor clearColor];
        __weak BankListView *weakSelf = self.bv;
        [UIView animateWithDuration:0.5 animations:^{
            weakSelf.frame = CGRectMake(0, ETScreenH, ETScreenW, ETScreenH);
        } completion:^(BOOL finished) {
            
        }];
    }
}

-(void)BankListViewdismiss
{
    self.bv.backgroundColor = [UIColor clearColor];
    __weak BankListView *weakSelf = self.bv;
    [UIView animateWithDuration:0.5 animations:^{
        weakSelf.frame = CGRectMake(0, ETScreenH, ETScreenW, ETScreenH);
    } completion:^(BOOL finished) {
        
    }];
}

- (BOOL)textFieldShouldReturn:(UITextField *)textField {
    
    [textField resignFirstResponder];//取消第一响应者
    
    return YES;
}
-(OpenDoc *)opendoc{
    if (!_opendoc) {
        _opendoc = [[OpenDoc alloc] init];
        _opendoc.delegate = self;
    }
    return _opendoc;
}

-(void)dealloc
{
    [self.bv removeFromSuperview];
    [self.toolbar removeFromSuperview];
    
}


@end
